<div class="modal fade" id="my-upload" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">上传图片</h4>
            </div>
            <div class="modal-body">
                <form method="post" name="upload_form" id="upload_form">
                    <input name="file" type="file" class="form-control"/>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" onclick="update()" class="btn btn-primary">上传</button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="my_upload_hint" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">提示</h4>
            </div>
            <div class="modal-body" id="my_upload_content">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <!--<button type="button" class="btn btn-primary">Save changes</button>-->
            </div>
        </div>
    </div>
</div>
<input type="hidden" id="inputShow" value="">
<script>
    function uploadImage(controlName) {
        $('#inputShow').val(controlName);
        $('#my-upload').modal();
    }
    function update() {
        $('#my-upload').modal('hide');
        var form = new FormData(document.getElementById("upload_form"));
//        console.info(form);
//        return;
        $.ajax({
            url: "__APP__/Admin/Public/upload",
            type: "POST",
            data: form,
            processData: false,
            contentType: false,
            success: function (data) {
                console.info(data);
                $('#my_upload_content').empty().append(data.message);
                $('#my_upload_hint').modal();
                if(data.success){
                    var controlName = $('#inputShow').val();
                    $('#'+controlName).val(data.path);
                }
            },
            error: function (e) {
            }
        });
    }
</script>